//
//  TYZTabBarController.m
//  TYZ_SC
//
//  Created by 李贤立 on 2017/12/12.
//  Copyright © 2017年 Capfer. All rights reserved.
//

#import "TYZTabBarController.h"
#import "ESTWorkbenchController.h"
#import "ESTClueOrSellTableViewController.h"
#import "ESTBacklogViewController.h"
#import "ESTDataAnalyseViewController.h"
#import "ESTMineViewController.h"
#import "ESTCustomerViewController.h"
#import "ESTWorkSpaceViewController.h"
#import "ESTMoreViewController.h"

@interface TYZTabBarController ()

@end

@implementation TYZTabBarController

- (void)viewWillLayoutSubviews{
    CGRect tabFrame = self.tabBar.frame;
    tabFrame.size.height = Value_TabBarControllerHeight;
    tabFrame.origin.y = self.view.frame.size.height - Value_TabBarControllerHeight;
    self.tabBar.frame = tabFrame;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    NSArray *nameArr;
    NSInteger type;// 顾问端是0Tab_001，经理端是1Tab_101
    UIViewController *vc1;
    UIViewController *vc2;
    UIViewController *vc3;
    UIViewController *vc5;
    if (CoreInfo.scrmType == SCRM_TYPE_MANAGER) {
        vc1 = [[ESTClueOrSellTableViewController alloc] init];
        ESTClueOrSellTableViewController *sellController = [[ESTClueOrSellTableViewController alloc] init];
        sellController.isSellMode = YES;
        vc2 = sellController;
        vc3 = [[ESTBacklogViewController alloc] init];
        ESTDataAnalyseViewController *vc4 = [[ESTDataAnalyseViewController alloc] init];
        ESTMineViewController *vc5 = [[ESTMineViewController alloc] init];
        self.viewControllers = @[vc1, vc2, vc3, vc4, vc5];
        nameArr = @[[@"线索" S],
                    [@"销售" S],
                    [@"待办" S],
                    [@"分析" S],
                    [@"我的" S]];
        type = 1;
    } else {
        vc1 = [[ESTWorkbenchController alloc] init];
        vc2 = [[ESTCustomerViewController alloc] init];
        vc3 = [[ESTWorkSpaceViewController alloc] init];
        vc5 = [[ESTMoreViewController alloc] init];
        self.viewControllers = @[vc1, vc2, vc3, vc5];
        nameArr = @[[@"工作台" S],
                    [@"客户" S],
                    [@"工作圈" S],
                    [@"更多" S]];
        type = 0;
    }
    
    [self.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSString *normalImageName = [NSString stringWithFormat:@"Tab_%ld%lu1", (long)type, (unsigned long)idx];
        NSString *selectedImageName = [NSString stringWithFormat:@"Tab_%ld%lu2", (long)type, (unsigned long)idx];
        obj.tabBarItem = [[UITabBarItem alloc] initWithTitle:nameArr[idx] image:[UIImage imageNamed:normalImageName] selectedImage:[UIImage imageNamed:selectedImageName]];
    }];
    self.tabBar.tintColor = ThemeColor;
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}
@end
